home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------
- // ADOBE SYSTEMS INCORPORATED
- // Copyright 2000-2002 Adobe Systems Incorporated
- // All Rights Reserved
- //
- // NOTICE: Adobe permits you to use, modify, and distribute
- // this file in accordance with the terms of the Adobe license
- // agreement accompanying it. If you have received this file
- // from a source other than Adobe, then your use, modification,
- // or distribution of it requires the prior written permission
- // of Adobe.
- //------------------------------------------------------------
-
- //------------------------------------------------------------
- // markupUtils.js
-
- // This file contains general purpose functions
- // for the JSXMarkup object
-
- // List of functions:
- //
- // getAncestorOfName(theName):
- // Return ancestor element of theName
- // theName: tagName of ancestor element to search for
- //
- // getChildCount(name)
- // For the markup element, return the number of children
- // of name. Children are defined as subElements whose
- // parent is the markup element. If name is not specified,
- // return total number of children.
- //
- // getChildren(name)
- // Return an array with children of the markup element.
- // Children are defined as subElements whose parent is
- // the markup element. Optional name parameter to get
- // only children with the given name.
- //
- // The function getSubElement returns all children and
- // children's children of the element.
- //
- // This implementation use the subElements
- // property to get all children of type tag.
-
-
- //-------------------------
- // getAncestorOfName
- //
- // this general purpose function returns the the
- // ancestor element of theName
- //
-
- function JSXMarkup_getAncestorOfName(theName)
- {
- var rtnVal = null;
- var theElt = this.parent;
-
- while (theElt != null)
- {
- if (theElt.elementType == "tag")
- {
- if (theElt.tagName == theName)
- {
- rtnVal = theElt;
- }
- }
- theElt = theElt.parent;
- }
- return rtnVal;
- }
-
- JSXMarkup.prototype.getAncestorOfName = JSXMarkup_getAncestorOfName;
-
- //----------------------------
- // getChildCount()
- //
- // Count the number of children of
- // theElt. Optionally, specify name
- // of children to count.
-
- function JSXMarkup_getChildCount(name)
- {
- var ct = 0;
- if (arguments.length == 0)
- {
- // count all children
- for (var i = 0; i < this.subElements.length; i++)
- {
- if (this.subElements[i].elementType == "tag")
- {
- ct++;
- }
- }
- }
- else
- {
- // count all children of name
- for (var i = 0; i < this.subElements.length; i++)
- {
- if ((this.subElements[i].elementType == "tag") &&
- (this.subElements[i].tagName == name))
- {
- ct++;
- }
- }
- }
-
- return ct;
- }
-
- JSXMarkup.prototype.getChildCount = JSXMarkup_getChildCount;
-
- //-------------------------------
- // getChildren()
- //
- // This function returns an array of the children of
- // the current element. Only children whose elementType
- // is tag are returned.
- // Optional parameter to specify the name of children
- // to get.
-
- function JSXMarkup_getChildren (name)
- {
- var childAry = new Array(0);
-
- if (arguments.length == 0)
- {
- for (var i = 0; i < this.subElements.length; i++)
- {
- if (this.subElements[i].elementType == "tag")
- {
- childAry.push(this.subElements[i]);
- }
- }
- }
- else {
- for (var i = 0; i < this.subElements.length; i++)
- {
- if ((this.subElements[i].elementType == "tag") &&
- (this.subElements[i].tagName == name))
- {
- childAry.push(this.subElements[i]);
- }
- }
- }
- return childAry;
- }
-
- JSXMarkup.prototype.getChildren = JSXMarkup_getChildren;